using System;
using System.Collections.Generic;

using System.Text;

using Mud.Common.Messages;
using Mud.Common.Physical;


namespace Mud.Client
{

    /// <summary>
    /// Maps some messages to client objects
    /// </summary>
    public static class MessageToObjectMapper {


        /// <summary>
        /// Maps the message object info to simple object.
        /// </summary>
        /// <param name="msg">The message.</param>
        public static SimpleObject MapToObject(MessageStructureSimpleObjectInfo msg)
        {
            SimpleObject o = new SimpleObject(msg.ObjectInfo.ObjectId);
            o.Name = msg.ObjectInfo.ObjectName;
            o.Location = new Location(msg.ObjectInfo.LocationX, msg.ObjectInfo.LocationY);
            o.CurrentAreaName = msg.ObjectInfo.AreaName;
            return o;
        }

        /// <summary>
        /// Maps the message creature info to creature.
        /// </summary>
        /// <param name="msg">The message.</param>
        public static Creature MapToObject(MessageStructureCreatureInfo msg)
        {
            Creature c = new Creature(msg.ObjectInfo.ObjectId);
            c.Name = msg.ObjectInfo.ObjectName;
            c.Location = new Location(msg.ObjectInfo.LocationX, msg.ObjectInfo.LocationY);
            c.CurrentAreaName = msg.ObjectInfo.AreaName;
            c.Orientation = msg.ObjectInfo.Orientation;
            return c;
        }

        /// <summary>
        /// Maps the message area info to area.
        /// </summary>
        /// <param name="msg">The message.</param>
        public static Area MapToObject(MessageStructureAreaInfo msg)
        {
            Area area = new Area(msg.AreaXDimension, msg.AreaYDimension);
            area.Name = msg.AreaName;
            return area;
        }


    }

}
